package com.chuangke.mds.runner;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

import com.chuangke.mds.entity.Knowledge;
import com.chuangke.mds.service.KnowledgeEsService;
import com.chuangke.mds.service.KnowledgeService;

@Component
@Order(2)
public class KnowledgeEsRunner implements CommandLineRunner {
	
	private static final Logger logger = LoggerFactory.getLogger(KnowledgeEsRunner.class);
	
	@Autowired
	private KnowledgeEsService knowledgeEsService;
	
	@Autowired
	private KnowledgeService knowledgeService;
	
    @Override
    public void run(String... args) {
    	logger.info("knowledgeEsService.reSyncData starting");
    	List<Knowledge> list = knowledgeService.getKnowledgeList();
    	knowledgeEsService.reSyncData(list);
    	logger.info("knowledgeEsService.reSyncData started");
    	
    }
}